package com.xu.seal.utils;

import com.xu.seal.common.SealConfiguration;
import com.xu.seal.config.SealConfig;

import java.io.File;
import java.util.UUID;

public class Main {

    public static void main(String[] args) throws Exception {

        String fileDir = "D:\\公章\\";
        batchCreateSeal(1000, fileDir);
    }

    public static void batchCreateSeal(Integer number, String fileDir) throws Exception {

        //String fileDir = "D:\\公章\\";
        //DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        //String fileName = fileDir + RandomStringUtils.generateRandomAlphaNumeric(32) + ".png";
        //String fileName = fileDir + UUID.randomUUID() + ".png";

        String filePrefix = ".jpg";
        for (int i = 0; i < 6; i++) {

            //生成目录
            File newDirectory = new File(fileDir + "\\" + i + "\\");
            if (!newDirectory.exists()) {
                // 创建目录
                boolean exist = newDirectory.mkdir();
            }else{
                System.out.println("开始删除旧的印章了……");
                File[] fileArray = newDirectory.listFiles();
                for (File file : fileArray) {
                    if (file.isFile()) file.delete();
                }
            }

            for (int j = 0; j < number; j++) {

                String mainText = new NameUtils().createRandomName();
                //生成公章
                SealConfiguration config = SealConfig.build(j, mainText);
                if (config != null) {
                    SealUtil.buildAndStoreSeal(config, newDirectory + "\\" + UUID.randomUUID() + filePrefix);
                }

            }
        }
    }

}
